<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta charset="UTF-8">
	<title>订单核销详情</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

  
<!-- 新模板 -->
<link rel="shortcut icon" href="<c:url value='/template/new_muban/images/favicon.ico'/>" type="image/x-icon"/>

<!-- 最新导入 -->
<script type="text/javascript" src="<c:url value='/template/new_muban/js/jquery-min-1.7.js'/>"></script>
<link rel="stylesheet" href="<c:url value='/template/new_muban/css/font.css'/>">
<link rel="stylesheet" href="<c:url value='/template/new_muban/css/xadmin.css'/>">   
<script src="<c:url value='/template/new_muban/lib/layui/layui.js'/>" charset="utf-8"></script> 
<script type="text/javascript" src="<c:url value='/template/new_muban/js/xadmin.js'/>"></script>

<link rel="stylesheet" href="<c:url value='/template/new_muban/css/login.css'/>">

<style type="text/css">
	/*圆形头像  */
	/* #divcss5{ margin:10px auto}  */
	#divcss5 img{ border-radius:50%} 
	.x-so input.layui-input {
    	width: 150px;
	}
</style>
</head>
<body>
   
     <div class="x-body">
               
	      
          <c:if test="${fn:length(findHXCodeByOrder) == 0 }">
          	<div class="layui-form-item layui-form-text">
	              <label for="desc" class="layui-form-label">
	               核销信息
	              </label>
	              <div class="layui-input-block">
	                  <table class="layui-table">
	                    <tbody>
	                      <tr>
	                        <td>无核销记录</div></td>
	                      </tr>
	                    </tbody>
	                  </table>
	              </div>
	          </div>
          </c:if>
          <c:if test="${fn:length(findHXCodeByOrder) > 0 }">
	          <div class="layui-form-item layui-form-text">
	              <label for="desc" class="layui-form-label">
	             核销信息
	              </label>
	              <div class="layui-input-block">
	                  <table class="layui-table">
	                    <tbody>
	                      <tr>
	                        <th>订单号</th>
	                        <th>门票名称</th>
	                        <th>核销码</th>
	                        <th>核销创建时间</th>
	                        <th>核销截止时间</th>
	                        <th>使用时间</th>
	                        <th>操作</th>
	                      </tr>
	                      <c:forEach items="${findHXCodeByOrder}" var="hxCode">
	                      <tr>
	                      	<td>${hxCode.order_no}</td>
	                      	<td>	
	                      		<div title='${hxCode.ticket_name}'> 
				            		<font size="1">
							             ${fn:substring(hxCode.ticket_name, 0,15)}
							             <c:if test="${fn:length(hxCode.ticket_name)>15}"> ... </c:if>
						             </font>
						          </div>
	                      	</td>
	                      	<td>${hxCode.oh_hexiaoma}</td>
	                      	<td><fmt:formatDate pattern="yyy-MM-dd HH:mm:ss" value="${hxCode.oh_createtime}"/></td>
	                      	<td><fmt:formatDate pattern="yyy-MM-dd HH:mm:ss" value="${hxCode.t_used_time}"/></td>
	                      	<td><fmt:formatDate pattern="yyy-MM-dd HH:mm:ss" value="${hxCode.oh_usetime}"/></td>
	                      	<td>
	                      		<c:if test="${dq_time_flag == 'normal'}">
		                      		<c:if test="${hxCode.oh_status == 0}"><button onclick="update_hx_code_status(${hxCode.oh_id});" class="layui-btn layui-btn-sm" title="核销"><span>核销</span></button></c:if>	                      		
		                      		<c:if test="${hxCode.oh_status == 1}">已核销</c:if>
	                      		</c:if>
	                      		<c:if test="${dq_time_flag == 'abnormal'}">
	                      			<c:if test="${hxCode.oh_status == 0}">已过期</c:if>	                      		
		                      		<c:if test="${hxCode.oh_status == 1}">已核销</c:if>
	                      		</c:if>
	                      	</td>
	                      </tr>
	                      </c:forEach>
	                    </tbody>
	                  </table>
	              </div>
	          </div>
          </c:if>
          
      </form>
    </div>
    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;
        
          //自定义验证规则
          form.verify({
            nikename: function(value){
              if(value.length < 5){
                return '昵称至少得5个字符啊';
              }
            }
            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }
          });

          //监听提交
          form.on('submit(add)', function(data){
            console.log(data);
            //发异步，把数据提交给php
            layer.alert("增加成功", {icon: 6},function () {
                // 获得frame索引
                var index = parent.layer.getFrameIndex(window.name);
                //关闭当前frame
                parent.layer.close(index);
            });
            return false;
          });
          
          
        });
    </script>
      <script type="text/javascript">
      /*
  	停用门票
  	*/
  	  function update_hx_code_status(oh_id){
          layer.confirm('确认要核销吗？',function(index){
          	
              //发异步删除数据
          	$.ajax({
                  type: "POST",
                  async : false, // 注意此处需要yi步  
                  url:  "<c:url value='/updateHXCodeByCode.do'/>",
                  data: {"oh_id":oh_id},
                  success: function(data){
                      if (data == 0) {
                      	layer.msg('核销失败,错误未知!',{icon: 2,time:3000});      
                      } else  {
                     	 	layer.msg("已核销", {icon: 6,time:500},function () {
                              //重新加载页面
                              location.reload();
                          });
   		           } 
                 }
   	        }); 
          });
      }
      
      </script>
  </body>
</html>